﻿/////////////////////////////////////////////////////////////////
//File: BlogInfo.cs
//Description: 
//Copyright© 2011 Moliu
//History:
//  2011-3-21 1:08:21    CodeSmith5.0.1    Original Version

/////////////////////////////////////////////////////////////////

using MAF.Common;
using MAF.CRUD;
using System.Web;
using System.Collections.Generic;

namespace My.Blog.Web.Controllers
{
    public class BlogSystemHandler
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        public BlogSystemHandler()
        {
            _blogSys = new BlogSystem();
        }

        /// <summary>
        /// 注册
        /// </summary>
        public void Register()
        {
            MyBlog info = MAF.Common.ObjectConverter.ToObject<MyBlog>(HttpContext.Current.Request.Form);
            _blogSys.Register(info);
        }

        //public void Update()
        //{
        //    T info = MAF.Common.ObjectConverter.ToObject<T>(HttpContext.Current.Request.Form);
        //    GetService().Update(info);
        //}

        //public int Delete()
        //{
        //    string ids = HttpContext.Current.Request.Form["Id"];
        //    return GetService().Delete(ids);
        //}

        //public virtual T Show()
        //{
        //    string id = HttpContext.Current.Request.QueryString["Id"];
        //    return GetService().Show(new Guid(id));
        //}

        //public virtual IList<T> Index()
        //{
        //    PageInfo p;
        //    return Index(out p);
        //}

        //public virtual IList<T> Index(out PageInfo page)
        //{
        //    ICRUD<T> svc = GetService();
        //    BaseQueryVo vo = svc.ParseToQueryVo(HttpContext.Current.Request.QueryString);
        //    IList<T> list = svc.Index(vo);

        //    page = vo.Page;         // 返回page
        //    return list;            // 返回list
        //}

        ///// <summary>
        ///// 提供使用固定ParentId的方法
        ///// </summary>
        ///// <param name="parentId"></param>
        ///// <returns></returns>
        //public virtual IList<T> Index(Guid parentId)
        //{
        //    BaseQueryVo vo = new BaseQueryVo();
        //    vo.ParentId = parentId.ToString();
        //    return GetService().Index(vo);
        //}

        protected BlogSystem _blogSys { get; private set; }
    }
}
